home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / program / gtld3656.lha / GadUtil / Docs / AutoDocs / 13.GU_GetGadgetPtr < prev    next >
Text File  |  1995-06-16  |  4KB  |  113 lines

  1. gadutil.library/GU_GetGadgetPtr               gadutil.library/GU_GetGadgetPtr
  2.  
  3.    NAME
  4.     GU_GetGadgetPtr -- Get a pointer to a gadget's gadget structure.
  5.  
  6.    SYNOPSIS
  7.     gad = GU_GetGadgetPtr(id, gadgets)
  8.     D0,SR(Z)              D0  A0
  9.  
  10.     struct Gadget *GU_GetGadgetPtr(UWORD, struct LayoutGadget *);
  11.  
  12.    FUNCTION
  13.     Find a gadget's gadget structure by giving its ID. The gadget
  14.     pointer is always found last in the LayoutGadget structure. You
  15.     can use this function to get that pointer.
  16.     It is also possible to get the gadget structure by taking it
  17.     directly from the LayoutGadget structure array, but then you
  18.     must know exactly in which structure it is located. Assembly
  19.     language programmers can use a PC relative pointer to get the
  20.     gadget pointer.
  21.     
  22.    INPUTS
  23.     id - the ID of the gadget to search for
  24.  
  25.     gadgets - a pointer to the array of LayoutGadget structures.
  26.  
  27.    RESULT
  28.     gad - pointer to the requested gadget. For bevelboxes, this
  29.           function will return a BBoxData structure.
  30.  
  31.    EXAMPLE
  32.  
  33.      Some of the LayoutGadget structures from BetterTest.c:
  34.  
  35.      struct LayoutGadget gadgets[] = {
  36.     { MSG_NEXTDRIVE, NextDriveGad, StdGTTags,   NULL },
  37.     { MSG_PREVDRIVE, PrevDriveGad, StdGTTags,   NULL },
  38.     { MSG_DRIVE,     DriveGad,     DriveGTTags, NULL },
  39.     { MSG_REQUESTER, ReqGad,       StdGTTags,   NULL },
  40.     { MSG_CHECKME,   CheckBoxGad,  StdGTTags,   NULL },
  41.     { MSG_FILENAME,  FileNameGad,  StdGTTags,   NULL },
  42.     { -1,            NULL,         NULL,        NULL }
  43.      };
  44.  
  45.     The examples should get the gadget structure of the Requester
  46.     gadget (not assuming that ID's begin with 0).
  47.     There is two methods you can use to get a gadgets structure:
  48.  
  49.     1. Use the pointer in the array directly:
  50.  
  51.     thegadget = gadgets[3].lg_Gadget
  52.  
  53.     This will only work if you know in which LayoutGadget structure
  54.     the gadget is in.
  55.  
  56.     2. Use this library function:
  57.  
  58.     thegadget = GU_GetGadgetPtr(MSG_REQUESTER, gadgets);
  59.  
  60.     This will always work if all gadgets have a unique ID.
  61.  
  62.  
  63.      Some of the LayoutGadget structures from BetterTest.s:
  64.  
  65.     gadgets:
  66.      GADGET  MSG_NEXTDRIVE,  NextDriveGad,   StdGTTags
  67.      GADGET  MSG_PREVDRIVE,  PrevDriveGad,   StdGTTags
  68.      GADGET  MSG_DRIVE,      DriveGad,       DriveGTTags
  69.      GADGET  MSG_REQUESTER,  ReqGad,         StdGTTags
  70.      GADGET  MSG_CHECKME,    CheckBoxGad,    StdGTTags
  71.      GADGET  MSG_FILENAME,   FileNameGad,    StdGTTags
  72.      GADGET  -1,NULL,NULL
  73.  
  74.      Assembly language programmers can use three methods to get the
  75.      pointer:
  76.  
  77.     1. Use the pointer in the array directly:
  78.  
  79.         lea.l    gadgets(pc),a0    ; Get array
  80.         moveq.l    #lg_SIZEOF,d0    ; Get the size of the LayoutGadget
  81.         mulu    #3,d0        ;  struct and calculate offset to
  82.                     ;  the right structure in the array
  83.         move.l    lg_Gadget(a0,d0.l),d0    ; Get the gadget pointer
  84.  
  85.     This will only work if you know in which LayoutGadget structure
  86.     the gadget is in.
  87.  
  88.     2. Use this library function:
  89.  
  90.         lea.l    gadgets(pc),a0    ; Get array
  91.         moveq.l    #MSG_REQUESTER,d0    ; Gadget to search for
  92.         jsr    _LVOGU_GetGadgetPtr    ; Get gadget, result in D0
  93.  
  94.     This will always work if all gadgets have a unique ID.
  95.  
  96.     3. Use an extra label for each gadget that should be easy to
  97.        access:
  98.  
  99.     gadgets:
  100.      GADGET  MSG_NEXTDRIVE,  NextDriveGad,   StdGTTags
  101.      GADGET  MSG_PREVDRIVE,  PrevDriveGad,   StdGTTags
  102.      GADGET  MSG_DRIVE,      DriveGad,       DriveGTTags
  103.      GADGET  MSG_REQUESTER,  ReqGad,         StdGTTags
  104.     reqgad:        equ    *-4
  105.      GADGET  MSG_CHECKME,    CheckBoxGad,    StdGTTags
  106.      GADGET  MSG_FILENAME,   FileNameGad,    StdGTTags
  107.     filenamegad:    equ    *-4
  108.      GADGET  -1,NULL,NULL
  109.  
  110.         move.l    reqgad(pc),d0        ; Get the gadget
  111.  
  112.     This will always work.
  113.